#!/bin/bash

# 检查是否在正确的目录或是否需要参数
PROJECT_ROOT="."
if [ "$#" -eq 1 ]; then
    PROJECT_ROOT="$1"
    # 创建项目根目录（如果不存在）
    mkdir -p "$PROJECT_ROOT"
elif [ "$#" -gt 1 ]; then
    echo "Usage: $0 [project_directory]"
    echo "  If no directory is provided, the structure will be created in the current directory."
    exit 1
fi

# 进入项目根目录
cd "$PROJECT_ROOT" || exit 1

echo "Creating project structure in: $(pwd)"

# 创建目录结构
mkdir -p proto
mkdir -p src
mkdir -p src/generated  # generated 通常由构建过程填充，但先创建空目录
mkdir -p include
mkdir -p build

# 创建空文件
# CMakeLists.txt
touch CMakeLists.txt

# Proto files
touch proto/graph_service.proto
touch proto/common_types.proto

# Source files
touch src/main.cpp
touch src/server.cpp
touch src/server.h
touch src/graph_db_client.cpp
touch src/graph_db_client.h

# Generated files (创建空的占位符文件，实际构建时会被覆盖)
touch src/generated/graph_service.grpc.pb.h
touch src/generated/graph_service.grpc.pb.cc
touch src/generated/graph_service.pb.h
touch src/generated/graph_service.pb.cc

# Include directory (通常用于项目公共头文件)
# (目录已创建，这里可以添加公共头文件，如果需要的话)

# Build directory (目录已创建，通常由 CMake 填充)

# README.md
touch README.md

echo "Project structure created successfully!"